package conceptmaniax.hotelapp.adapters;

public class PhoneItem extends Simple implements Comparable<PhoneItem> {

	private String phoneNumber;
	
	public PhoneItem() { 
		super();
	}
	
	public PhoneItem(final int id, final String name, final String phonenumber) {
		super(id, name);
		this.phoneNumber = phonenumber;
	}
	
	public PhoneItem(final int id, final String code, final String name, final String phonenumber) {
		super(id, code, name);
		this.phoneNumber = phonenumber;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}
	
	@Override
	public int compareTo(final PhoneItem obj) {
		if (this == obj) {
			return 0;
		}

		if (!(obj instanceof PhoneItem)) {
			throw new ClassCastException("Invalid object");
		}

		return ( this.getId() > ((PhoneItem) obj).getId() )?1:-1;
	}
	
	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof PhoneItem)) {
			return false;
		}

		return (this.getId() == ((PhoneItem) obj).getId());
	}

	@Override
	public int hashCode() {
		return 31 * 7 * this.getId();
	}

	@Override
	public String toString() {
		return "PhoneItem [phoneNumber=" + phoneNumber + super.toString() + "]";
	}	
}
